<template>
	<view class="formdata">
		<view class="formdata-item">
			<view class="text">
				<text>班级名称</text>
			</view>
			<view class="input">
				{{DAT.CLASSNAME}}
			</view>
		</view>
	</view>
	<view class="formdata">
		<view class="formdata-item">
			<view class="text">
				<text>状态</text>
			</view>
			<view class="input">
				<view class="isopinion-info">
					<radio-group @change="onSelectStatus">
						<view class="">
							<view>
								<label class="text-sm">启用</label>
								<radio
										:class="['radio','blue',DAT.STATE === '1' ? 'checked' : '']"
										:checked="DAT.STATE === '1'"
										value="1"
										style="transform: scale(0.8)"
								>
								</radio>
					
								<label class="text-sm">停用</label>
								<radio
										:class="['radio','blue',curSelectStatus === '0' ? 'checked' : '']"
										:checked="DAT.STATE === '0'"
										value="0"
										style="transform: scale(0.8)"
								>
								</radio>
							</view>
						</view>
					</radio-group>
				</view>
			</view>
		</view>
	</view>
	<view class="upload">
		<view style="margin-top: 20rpx;">
			<button class="cu-btn bg-blue shadow-blur" style="float: right;" @tap="uploadImage()">上传图片</button>
		</view>
		<view class="image">
			<image :src="DAT.WX_PIC" mode="widthFix"></image>
		</view>
	</view>
	<view class="submit">
		<button class="cu-btn bg-blue shadow-blur radius" @tap="uploadImageSubmit()">提交修改</button>
	</view>
</template>

<script lang="ts" setup>
	import {onLoad} from "@dcloudio/uni-app";
	import {ref} from "vue"
	import {useStore} from "vuex";
	import {usesetUploadImage} from "./useClassImageEdit"
	const { initsetUploadImage }:any = usesetUploadImage()
	const DAT = ref<any>({})
	const {state} = useStore()
	let isload:boolean = false 
	onLoad((option)=>{
		DAT.value = JSON.parse(decodeURIComponent(option.DATA))
		isload = true
	})
	function onSelectStatus(e){
		DAT.value.STATE= e.detail.value
	}
	function uploadImage(){
		uni.chooseImage({   //上传图片的内置方法
			count:1, //在h5浏览器限制不住
			sizeType:['compressed '],
            sourceType: ['album'], //从相册选择
			success:res=>{
				isload = false
				DAT.value.WX_PIC = res.tempFilePaths[0]
			}
		})
	}
	function uploadImageSubmit(){
		uni.showModal({
			title: '提示消息',
			content: '您确定提交吗',
			success: res => {
				if (res.confirm){
					initsetUploadImage({
						url:DAT.value.WX_PIC,
						CLASS_ID:DAT.value.CLASS_ID,
						STATE:DAT.value.STATE,
						WX_PIC:DAT.value.WX_PIC,
						isload:isload,
						wx_pic:DAT.value.wx_pic
					})
				}
				
			},
			fail: () => {},
			complete: () => {}
		})
	}
</script>

<style lang="scss">
	.formdata {
		background-color: white;
		.formdata-item {
			padding: 0 32rpx 0 32rpx;
			border-bottom: 4rpx #F7F8FC solid;
			width: 100%;
			height: 110rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.text {
				margin-right: 32rpx;
			}
		}
	}
	.image{
		display: flex;
		justify-content: center;
		width: 100%;
		image{
			padding-top: 20rpx;
			display: flex;
			justify-content: center;
		}
	}
	.submit{
		position: fixed;
		bottom: 20rpx;
		margin-left: 40%;
	}
</style>